#include "List.h"

void test1()
{
	ListNode* head = ListCreate();

	ListPushBack(head, 1);
	ListPushBack(head, 2);
	ListPushBack(head, 3);
	ListPushBack(head, 4);
	ListPushBack(head, 5);
	ListPrint(head);

	ListPopBack(head);
	ListPopBack(head);
	ListPopBack(head);
	ListPrint(head);

	ListPopBack(head);
	ListPrint(head);

	ListPopBack(head);
	ListPrint(head);

	/*ListPopBack(head);*/
}


void test2()
{
	ListNode* head = ListCreate();

	ListPushBack(head, 1);
	ListPushBack(head, 2);
	ListPushBack(head, 3);
	ListPushBack(head, 4);
	ListPushBack(head, 5);
	ListPrint(head);

	/*ListPushFront(head, 10);
	ListPushFront(head, 20);
	ListPushFront(head, 30);
	ListPushFront(head, 40);
	ListPushFront(head, 50);
	ListPrint(head);*/

	ListPopFront(head);
	ListPrint(head);

	ListPopFront(head);
	ListPrint(head);

	ListPopFront(head);
	ListPrint(head);
	ListPopFront(head);
	ListPrint(head);
	ListPopFront(head);
	ListPrint(head);
}


void test3()
{
	ListNode* head = ListCreate();
	ListPushBack(head, 1);
	ListPushBack(head, 2);
	ListPushBack(head, 3);
	ListPushBack(head, 4);
	ListPushBack(head, 5);
	ListPrint(head);


	ListNode* pos = ListFind(head, 2);
	if (pos != NULL)
	{
		ListInsert(pos, 20);
	}
	ListPrint(head);

	pos = ListFind(head, 3);
	if (pos != NULL)
	{
		ListInsert(pos, 30);
	}
	ListPrint(head);
}

void test4()
{
	ListNode* head = ListCreate();
	ListPushBack(head, 1);
	ListPushBack(head, 2);
	ListPushBack(head, 3);
	ListPushBack(head, 4);
	ListPushBack(head, 5);
	ListPrint(head);

	ListNode* pos = ListFind(head, 2);
	if (pos != NULL)
	{
		ListErase(pos);
	}
	ListPrint(head);

	pos = ListFind(head, 3);
	if (pos != NULL)
	{
		ListErase(pos);
	}
	ListPrint(head);
}

void test5()
{
	ListNode* head = ListCreate();
	ListPushBack(head, 1);
	ListPushBack(head, 2);
	ListPushBack(head, 3);
	ListPushBack(head, 4);
	ListPushBack(head, 5);
	ListPrint(head);

	ListDestroy(head);
}


int main()
{
	test5();

	return 0;
}

